import request from '@/utils/request'

export default {
  // 用户管理
  getUserList(searchModel) {
    const params = JSON.stringify({
      page: searchModel.page,
      pageSize: searchModel.pageSize,
      search_key: searchModel.search_key
    })
    console.log(params);
    return request({
      url: '/system-item-setting/list',
      method: 'post',
      headers: {
        'Content-Type': 'application/json'
      },
      data: params
      // data: { params, ...searchModel.search_key }
    });
  },
  getContactUsrList(searchModel) {
    const params = JSON.stringify({
      // page: searchModel.page,
      // pageSize: searchModel.pageSize,
      identification: searchModel.search_key.identification,
      type: searchModel.search_key.type,
      // identification: "call"
    })
    console.log(params);
    return request({
      url: '/planting/contactUs',
      method: 'post',
      headers: {
        'Content-Type': 'application/json'
      },
      data: params
    });
  },
  addUser(user) {
    return request({
      url: '/system-item-setting/add',
      method: 'post',
      data: user
    });
  },
  // 修改
  updateUser(user) {
    return request({
      url: '/system-item-setting/update',
      method: 'post',
      data: { ...user }
    });
  },
  saveUser(user) {
    // if(user.id == null && user.id == undefined){
    //   return this.addUser(user);
    // }
    // 添加
    if (!user.id) {
      return this.addUser(user);
    }
    return this.updateUser(user);
  },
  // 删除
  deleteUserById(id) {
    return request({
      url: `/system-item-setting/delete`,
      method: 'post',
      data: { id }
    });
  },
}
